package com.guptarulie.jmeter.protocol.mm7.cancelreplace;

//import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
//import java.io.BufferedReader;
//import java.io.BufferedWriter;
import java.io.InputStream;
//import java.io.InputStreamReader;
//import java.io.OutputStreamWriter;
import java.net.InetAddress;
import java.net.Socket;
import java.util.Date;
import java.util.Enumeration;

import javax.mail.internet.InternetHeaders;


import org.apache.jmeter.samplers.AbstractSampler;
import org.apache.jmeter.samplers.Entry;
import org.apache.jmeter.samplers.SampleResult;
import org.apache.jmeter.testbeans.TestBean;
import org.apache.jorphan.logging.LoggingManager;
import org.apache.log.Logger;

/**
 *User: Mat Rule
 *User: Gaurav Gupta
 *Date: Jan 2009
 */

public class MM7CancelReplaceReqSampler extends AbstractSampler implements TestBean {

	/**
	 * 
	 */
	private static final long serialVersionUID = -4459287513364056191L;
	private static final String vaspLocalIP = "MM7CancelReplaceReqSampler.vaspLocalIP";
	private static final String vaspLocalPort = "MM7CancelReplaceReqSampler.vaspLocalPort";
	private static final String vaspUserName = "MM7CancelReplaceReqSampler.vaspUserName" ;
	private static final String vaspPwd = "MM7CancelReplaceReqSampler.vaspPwd";
	private static final String vaspConnType = "MM7CancelReplaceReqSampler.vaspConnType";
	private static final String vaspID = "MM7CancelReplaceReqSampler.vaspID";
	private static final String vasID = "MM7CancelReplaceReqSampler.vasID";
	private static final String vaspURL = "MM7CancelReplaceReqSampler.vaspURL";
	private static final String mmscServerName = "MM7CancelReplaceReqSampler.mmscServerName";
	private static final String mmscPortNumber = "MM7CancelReplaceReqSampler.mmscPortNumber";
	private static final String mmscUserName = "MM7CancelReplaceReqSampler.mmscUserName";
	private static final String mmscPwd = "MM7CancelReplaceReqSampler.mmscPwd";
	private static final String mmscConnType = "MM7CancelReplaceReqSampler.mmscConnType";
	private static final String mmSenderAddr = "MM7CancelReplaceReqSampler.mmSenderAddr";
	private static final String mmRecipientAddr = "MM7CancelReplaceReqSampler.mmRecipientAddr";
	private static final String serviceCode = "MM7CancelReplaceReqSampler.serviceCode";
	private static final String msgClass = "MM7CancelReplaceReqSampler.msgClass";
	private static final String deliveryReport = "MM7CancelReplaceReqSampler.deliveryReport";
	private static final String readReplyReport = "MM7CancelReplaceReqSampler.readReplyReport";
	private static final String contentType = "MM7CancelReplaceReqSampler.contentType";
	private static final String replaceCancel = "MM7CancelReplaceReqSampler.replaceCancel";
	private static final String timerValue = "MM7CancelReplaceReqSampler.timerValue";
	
    private static final Logger log = LoggingManager.getLoggerForClass();
    private static final String ISO_8859_1 = "ISO-8859-1"; //$NON-NLS-1$
    // Buffer to hold the input socket stream
    private StringBuffer inputMsgBuffer;
    private static final String SUCCESS = "1000";
    private static final String CANCEL = "CANCEL";
    private static final String REPLACE = "REPLACE";
    private static final String TRUE = "True";
    private static final String FALSE = "False";

    private static long increment;
	
 
//	@Override
	public SampleResult sample(Entry entry) {
		// TODO Auto-generated method stub
        
        SampleResult result = new SampleResult();
        String responseCode = new String();
//        BufferedInputStream in = null;
        BufferedOutputStream out = null;
        
        try {
        
        result.setDataEncoding(SampleResult.DEFAULT_HTTP_ENCODING);
        result.setDataType(SampleResult.TEXT);
        result.setSampleLabel(getName());
        

        //set the start
        result.sampleStart();
        
        String hostname = getmmscServerName();
        int port = new Integer(getmmscPortNumber());
        InetAddress  addr = InetAddress.getByName(hostname);
        Socket sock = new Socket(addr, port);
        
        // Set the time out to 5 seconds...
        sock.setSoTimeout(5000);
        
    	InputStream inputStream = sock.getInputStream();
//    	in = new BufferedInputStream(inputStream);
        out = new BufferedOutputStream(sock.getOutputStream());

     
        String msgString = getReplaceCancelString();


        //SendMM7Submit Message and return the response data
    	sendSubmitRequest(out, result);
        processInputStream(inputStream);
        if (checkMessageType("SubmitRsp"))
        {
            //quick way of pulling out the result
            String rspCodeValue = fetchInformationElementValue("StatusCode>");
            
            if ( rspCodeValue.equals(SUCCESS) )
            {
            	// Fetch the Message ID from the Submit Response
            	String messageID = fetchInformationElementValue("MessageID");
            	if (messageID == null)
            	{
            		log.error("Incorrect Submit Response. No Message ID inside it...");
            		result.setSuccessful(false);
            	}
            	
            	// SubmitReq submitted successfully. Now, send the Cancel/Replace message
            	if( msgString.equals(CANCEL) )
            	{
            		sendCancelRequest( out, messageID );
            	}
            	else if (msgString.equals(REPLACE))
            	{
            		sendReplaceRequest( out, messageID );
            	}
            	else
            	{
            		log.error("Message Selection is neither Cancel nor Replace. So, Quitting!");
            		result.setSuccessful(false);
            	}
            	
            	// Process the input. Should be either CancelRsp or ReplaceRsp only...
                processInputStream(inputStream);
                if (checkMessageType("CancelRsp") || checkMessageType("ResponseRsp"))
                {
//                	quick way of pulling out the result
                    responseCode = fetchInformationElementValue("StatusCode>");
                    if ( responseCode.equals(SUCCESS) )
                    {
                        result.setSuccessful(true);
                        log.info("The test case PASSED...");

                    }
                    else
                    {
                        result.setSuccessful(false);
                        log.info("The test case FAILED...");

                    }
                    
                }
                else
                {
                	log.error("Only CancelRsp or ReplaceRsp expected...");
                	result.setSuccessful(false);
                }
            	
           }
            else
            {
                // end sample
              result.setSuccessful(false);
         
            }

        }
        else
        {
        	result.setSuccessful(false);
        	log.error("Submit Response is expected after Submit Response...");
        }

        result.sampleEnd();
    	result.setResponseCode(responseCode);
        result.setResponseData(inputMsgBuffer.toString().getBytes());
        }
        catch (Exception e){
        	log.error("", e);
        }
      
		return result;
	}
	

	    
    private StringBuffer sendSubmitRequest(BufferedOutputStream bufWriter, SampleResult result) {
        StringBuffer responseData = new StringBuffer();
        try {
    	
            StringBuffer xmlContents = new StringBuffer();
            StringBuffer httpContents = new StringBuffer();
            String utf8UserPass = getmmscUserName() + ":" + getmmscPwd();
            String authHeaderValue = new sun.misc.BASE64Encoder().encode(utf8UserPass.getBytes());
        
        
            //create a new individual transaction id. use millisecond time+a static increment+threadname
            long epochTime = new Date().getTime();
            increment++;
            String transId = epochTime + "-" + increment + "-" + getThreadName().toString();
            	
            // keep separate so we can quickly calculate length
			xmlContents.append("-----mime-boundary-F032A15B.98A2DA1C---\r\n");
			xmlContents.append("Content-Type: text/xml; charset=utf-8\r\n");
			xmlContents.append("Content-ID: <mm7_msg>\r\n");
			xmlContents.append("\r\n");
			xmlContents.append("<?xml version='1.0' ?>\r\n");
			xmlContents.append("<env:Envelope xmlns:env=\"http://schemas.xmlsoap.org/soap/envelope/\">\r\n");
			xmlContents.append("<env:Header>\r\n");
			xmlContents.append("<mm7:TransactionID xmlns:mm7=\"http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-2\" env:mustUnderstand=\"1\">\r\n");
			xmlContents.append(transId + "\r\n");
			xmlContents.append("</mm7:TransactionID>\r\n");
			xmlContents.append("</env:Header>\r\n");
			xmlContents.append("<env:Body>\r\n");
			xmlContents.append("<SubmitReq xmlns=\"http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-2\">\r\n");
			xmlContents.append("<MM7Version>5.3.0</MM7Version>\r\n");
			xmlContents.append("<SenderIdentification>\r\n");
			xmlContents.append("<VASPID>" + getvaspID() + "</VASPID>\r\n");
			xmlContents.append("<VASID>" + getvasID() + "</VASID>\r\n");
			xmlContents.append("</SenderIdentification>\r\n");
			xmlContents.append("<Recipients>\r\n");
			xmlContents.append("<To>\r\n");
			xmlContents.append("<Number>" + getmmRecipientAddr() +"</Number>\r\n");
			xmlContents.append("</To>\r\n");
			xmlContents.append("</Recipients>\r\n");
			xmlContents.append("<ServiceCode>"+ getserviceCode() +"</ServiceCode>\r\n");
			xmlContents.append("<LinkedID>"+ "NULL" +"</LinkedID>\r\n");
			xmlContents.append("<MessageClass>"+ getmsgClass() +"</MessageClass>\r\n");
			xmlContents.append("<DeliveryReport>"+ getDeliveryReportString() +"</DeliveryReport>\r\n");
			xmlContents.append("<ReadReply>"+ getReadReplyReportString() +"</ReadReply>\r\n");
			xmlContents.append("<Subject>JMeter Test #" + transId + "</Subject>\r\n");
			xmlContents.append("<Content href=\"cid:mms_cid\" />\r\n");
			xmlContents.append("</SubmitReq>\r\n");
			xmlContents.append("</env:Body>\r\n");
			xmlContents.append("</env:Envelope>\r\n");
			xmlContents.append("\r\n");
			xmlContents.append("-----mime-boundary-F032A15B.98A2DA1C---\r\n");
			xmlContents.append("Content-Type: multipart/mixed; boundary=\"---mime-boundary-C97CAD9D.029FABDE---\"\r\n");
			xmlContents.append("Content-ID: <mms_cid>\r\n");
			xmlContents.append("\r\n");
			xmlContents.append("-----mime-boundary-C97CAD9D.029FABDE---\r\n");
			xmlContents.append("Content-Type: text/plain\r\n");
			xmlContents.append("Content-ID: <40F64F99.txt>\r\n");
			xmlContents.append("Content-location: 40F64F99.txt\r\n");
			xmlContents.append("\r\n");
			xmlContents.append("test from jmeter, hello world!\r\n");
			xmlContents.append("-----mime-boundary-C97CAD9D.029FABDE-----\r\n");
			xmlContents.append("\r\n");
			xmlContents.append("-----mime-boundary-F032A15B.98A2DA1C----- ");
			xmlContents.append("\r\n");

			httpContents.append("POST /mm7 HTTP/1.0\r\n");
			httpContents.append( ("Authorization: Basic " + authHeaderValue + "\r\n" ) );
			httpContents.append("Host: "+getvaspURL()+"\r\n");
			httpContents.append("Content-Length: " + xmlContents.length() + "\r\n");
			httpContents.append("Content-Type: multipart/related; boundary=\"---mime-boundary-F032A15B.98A2DA1C---\"; type=\"text/xml\"; start=\"<mm7_msg>\""+"\r\n");
			httpContents.append("SOAPAction: \"\"\r\n");
			httpContents.append("\r\n");
			
            // add the http and xml contents buffers to the mix
			bufWriter.write(httpContents.toString().getBytes(ISO_8859_1));
			bufWriter.write(xmlContents.toString().getBytes(ISO_8859_1));
            
			//Send data
			bufWriter.flush();
            
            //write the request data
            result.setRequestHeaders(httpContents.toString()+"\n\r"+xmlContents.toString());
            result.setSamplerData("");

            } 

        catch (Exception e) {
                log.error("", e);;
        }

		return responseData;
    }

    private void sendCancelRequest(BufferedOutputStream bufWriter, String msgID)
    {
        StringBuffer xmlContents = new StringBuffer();
        StringBuffer httpContents = new StringBuffer();
 
        try {
	        //create a new individual transaction id. use millisecond time+a static increment+threadname
	        long epochTime = new Date().getTime();
	        increment++;
	        String transId = epochTime + "-" + increment + "-" + getThreadName().toString() + msgID;
	        	
	        //keep seperate so we can quickly calculate length
			xmlContents.append("<?xml version='1.0' ?>\r\n");
			xmlContents.append("<env:Envelope xmlns:env=\"http://schemas.xmlsoap.org/soap/envelope/\">\r\n");
			xmlContents.append("<env:Header>\r\n");
			xmlContents.append("<mm7:TransactionID xmlns:mm7=\"http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-2\" env:mustUnderstand=\"1\">\r\n");
			xmlContents.append(transId+"\r\n");
			xmlContents.append("</mm7:TransactionID>\r\n");
			xmlContents.append("</env:Header>\r\n");
			xmlContents.append("<env:Body>\r\n");
			xmlContents.append("<CancelReq xmlns=\"http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-2\">\r\n");
			xmlContents.append("<MM7Version>5.3.0</MM7Version>\r\n");
			xmlContents.append("<SenderIdentification>\r\n");
			xmlContents.append("<VASPID>"+ getvaspID() +"</VASPID>\r\n");
			xmlContents.append("<VASID>my id</VASID>\r\n");
			xmlContents.append("</SenderIdentification>\r\n");
			xmlContents.append("<MessageID>" + msgID + "</MessageID>\r\n");
			xmlContents.append("</CancelReq>\r\n");
			xmlContents.append("</env:Body>\r\n");
			xmlContents.append("</env:Envelope>\r\n");
			xmlContents.append("\r\n");
			xmlContents.append("\r\n");
	
			httpContents.append("POST /mm7 HTTP/1.0\r\n");
	//		httpContents.append( ("Authorization: Basic " + authHeaderValue + "\r\n" ) );
	//		httpContents.append("Host: "+getmm7ServerName()+"\r\n");
			httpContents.append("Content-Type: text/xml; charset=\"utf-8\"" + "\r\n");
			httpContents.append("Content-Length: " + xmlContents.length() + "\r\n");
			httpContents.append("SOAPAction: \"\"\r\n");
			httpContents.append("\r\n");
			
	        // add the http and xml contents buffers to the mix
			bufWriter.write(httpContents.toString().getBytes(ISO_8859_1));
			bufWriter.write(xmlContents.toString().getBytes(ISO_8859_1));
	        
			//Send data
			bufWriter.flush();
	        
	        } 

        catch (Exception e) {
            log.error("", e);
        }
    }
    
    private void sendReplaceRequest(BufferedOutputStream bufWriter, String msgID)
    {
        StringBuffer xmlContents = new StringBuffer();
        StringBuffer httpContents = new StringBuffer();
 
       try {
        //create a new individual transaction id. use millisecond time+a static increment+threadname
        long epochTime = new Date().getTime();
        increment++;
        String transId = epochTime + "-" + increment + "-" + getThreadName().toString() + msgID;
        	
        //keep seperate so we can quickly calculate length
		xmlContents.append("-----mime-boundary-F032A15B.98A2DA1C---\r\n");
		xmlContents.append("Content-Type: text/xml; charset=utf-8\r\n");
		xmlContents.append("Content-ID: <mm7_msg>\r\n");
		xmlContents.append("\r\n");
		xmlContents.append("<?xml version='1.0' ?>\r\n");
		xmlContents.append("<env:Envelope xmlns:env=\"http://schemas.xmlsoap.org/soap/envelope/\">\r\n");
		xmlContents.append("<env:Header>\r\n");
		xmlContents.append("<mm7:TransactionID xmlns:mm7=\"http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-2\" env:mustUnderstand=\"1\">\r\n");
		xmlContents.append(transId+"\r\n");
		xmlContents.append("</mm7:TransactionID>\r\n");
		xmlContents.append("</env:Header>\r\n");
		xmlContents.append("<env:Body>\r\n");
		xmlContents.append("<ReplaceReq xmlns=\"http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-2\">\r\n");
		xmlContents.append("<MM7Version>5.3.0</MM7Version>\r\n");
		xmlContents.append("<SenderIdentification>\r\n");
		xmlContents.append("<VASPID>"+getvaspID()+"</VASPID>\r\n");
		xmlContents.append("<VASID>my id</VASID>\r\n");
		xmlContents.append("</SenderIdentification>\r\n");
		xmlContents.append("<MessageID>" + msgID + "</MessageID>\r\n");
		xmlContents.append("<Content href=\"cid:mms_cid\" />\r\n");
		xmlContents.append("</ReplaceReq>\r\n");
		xmlContents.append("</env:Body>\r\n");
		xmlContents.append("</env:Envelope>\r\n");
		xmlContents.append("\r\n");
		xmlContents.append("-----mime-boundary-F032A15B.98A2DA1C---\r\n");
		xmlContents.append("Content-Type: multipart/mixed; boundary=\"---mime-boundary-C97CAD9D.029FABDE---\"\r\n");
		xmlContents.append("Content-ID: <mms_cid>\r\n");
		xmlContents.append("\r\n");
		xmlContents.append("-----mime-boundary-C97CAD9D.029FABDE---\r\n");
		xmlContents.append("Content-Type: text/plain\r\n");
		xmlContents.append("Content-ID: <40F64F99.txt>\r\n");
		xmlContents.append("Content-location: 40F64F99.txt\r\n");
		xmlContents.append("\r\n");
		xmlContents.append("test from jmeter, hello world!\r\n");
		xmlContents.append("-----mime-boundary-C97CAD9D.029FABDE-----\r\n");
		xmlContents.append("\r\n");
		xmlContents.append("-----mime-boundary-F032A15B.98A2DA1C----- ");
		xmlContents.append("\r\n");

		httpContents.append("POST /mm7 HTTP/1.0\r\n");
//		httpContents.append( ("Authorization: Basic " + authHeaderValue + "\r\n" ) );
		httpContents.append("Host: "+getvaspURL()+"\r\n");
		httpContents.append("Content-Length: " + xmlContents.length() + "\r\n");
		httpContents.append("Content-Type: multipart/related; boundary=\"---mime-boundary-F032A15B.98A2DA1C---\"; type=\"text/xml\"; start=\"<mm7_msg>\""+"\r\n");
		httpContents.append("SOAPAction: \"\"\r\n");
		httpContents.append("\r\n");
		
        // add the http and xml contents buffers to the mix
		bufWriter.write(httpContents.toString().getBytes(ISO_8859_1));
		bufWriter.write(xmlContents.toString().getBytes(ISO_8859_1));
        
		//Send data
		bufWriter.flush();
        
        //write the request data
//        result.setRequestHeaders(httpContents.toString()+"\n\r"+xmlContents.toString());
//        result.setSamplerData("");

        } 

    catch (Exception e) {
            log.error("", e);;
    }

    }
    private String processInputStream(InputStream inStream)
    {
  	  inputMsgBuffer = new StringBuffer();
  	  String contentType = new String();
  		try {
  			InternetHeaders headers = new InternetHeaders( inStream );
  			Enumeration enumeration = headers.getAllHeaderLines();
  			
  			while( enumeration.hasMoreElements() )
  			{
  				inputMsgBuffer.append( ( String ) enumeration.nextElement() );
  				inputMsgBuffer.append( "\r\n" );
  			}
  			
  			inputMsgBuffer.append( "\r\n" );
  			
  			int contentLength = 0;
  			try {
  				String[] contentLengthStr = headers.getHeader( "content-length" );
  				if( contentLengthStr != null && contentLengthStr[0] != null )
  					contentLength = Integer.parseInt( contentLengthStr[0] );
  			} catch( NumberFormatException nfe ) {
  				log.error("", nfe);
  			}
  				
  			log.info("Content Length: " + contentLength);
  			if (contentLength == 0)
  			{
  				log.error("Content Length is 0. Quitting...");
  				return null;
  			}
  			
  			byte[] buf = new byte[4096];
  			int totalBytesRead = 0;
  			int bytesRead;
  			while( totalBytesRead < contentLength )
  			{
  				bytesRead = inStream.read( buf );
  				if(bytesRead == -1 ) 
  					break;
  				inputMsgBuffer.append( new String( buf, 0, bytesRead ) );
  				totalBytesRead += bytesRead;
  			}
  			log.info("Total bytes read:" + totalBytesRead);
  			
  			String contentTypes[] = headers.getHeader( "content-type" );
  			contentType = contentTypes[0];
  			
  			log.info("Content Type: " + contentType);
  			log.info("Input Message: " + inputMsgBuffer.toString());
  			
  		} catch (Exception except) {
  			log.error("", except);
  		}
  		return contentType;
  		
   }

    private String fetchInformationElementValue(String ieString)
    {
    	String ieValue = new String();
    	try 
	    {
  			int tagBeginIndex = inputMsgBuffer.toString().indexOf(ieString);
  			if (tagBeginIndex == -1)
  			{
  				log.info(ieString+ " Not found in the Input Buffer");
  				return null;
  			}
  			
  			int tagIDStart = inputMsgBuffer.toString().indexOf(">", tagBeginIndex);
  			int tagIDEnd =  inputMsgBuffer.toString().indexOf("</", tagIDStart);
  			
  			ieValue = inputMsgBuffer.toString().substring(tagIDStart + 1, tagIDEnd);
  			log.info("Value of " + ieString + ":" + ieValue);
  	  	
	    }
	  	catch (Exception except) {
	  		 log.error("", except);
	  	}
	  	
	  	return ieValue;
    }
    
    private boolean checkMessageType(String msgType)
    {
    	if (inputMsgBuffer.indexOf(msgType) != -1)
    		return false;
    	else
    		return true;
    }
    
    private String getReplaceCancelString()
    {
       if (getReplaceCancel().indexOf("Cancel") != -1 ) {
        	return CANCEL;
        } else if(getReplaceCancel().indexOf("Replace") != -1 ) {
        	return REPLACE;
        } else 
        	return null;
    }
    

    private String getDeliveryReportString()
    {
       if (getdeliveryReport().indexOf("Yes") != -1 ) {
        	return TRUE;
        } else if(getdeliveryReport().indexOf("No") != -1 ) {
        	return FALSE;
        } else 
        	return null;
    }
    
    private String getReadReplyReportString()
    {
        if (getreadReplyReport().indexOf("Yes") != -1 )
        	return TRUE;
        else if(getreadReplyReport().indexOf("No") != -1 )
        	return FALSE;
        else 
        	return null;
    }
   
    
	public String getvaspLocalIP() {
        return getPropertyAsString(vaspLocalIP);
    }

    public void setvaspLocalIP(String newvaspLocalIP) {
    	this.setProperty(vaspLocalIP, newvaspLocalIP);
    }

	public String getvaspLocalPort() {
        return getPropertyAsString(vaspLocalPort);
    }

    public void setvaspLocalPort(String newvaspLocalPort) {
    	setProperty(vaspLocalPort, newvaspLocalPort);
    }

	public String getvaspUserName() {
        return getPropertyAsString(vaspUserName);
    }

    public void setvaspUserName(String newvaspUserName) {
    	setProperty(vaspUserName , newvaspUserName);
    }

	public String getvaspPwd() {
        return getPropertyAsString(vaspPwd);
    }

    public void setvaspPwd(String newvaspPwd) {
    	setProperty(vaspPwd , newvaspPwd);
    }
    
	public String getvaspConnType() {
        return getPropertyAsString(vaspConnType);
    }

    public void setvaspConnType(String newvaspConnType) {
    	setProperty(vaspConnType, newvaspConnType);
    }
    
	public String getvaspID() {
        return getPropertyAsString(vaspID);
    }

    public void setvaspID(String newvaspID) {
    	setProperty(vaspID, newvaspID);
    }
    
	public String getvasID() {
        return getPropertyAsString(vasID);
    }

    public void setvasID(String newvasID) {
    	setProperty(vasID , newvasID);
    }
    
	public String getvaspURL() {
        return getPropertyAsString(vaspURL);
    }

    public void setvaspURL(String newvaspURL) {
    	setProperty(vaspURL, newvaspURL);
    }
    
	public String getmmscServerName() {
        return getPropertyAsString(mmscServerName);
    }

    public void setmmscServerName(String newmmscServerName) {
    	setProperty(mmscServerName, newmmscServerName);
    }
    
	public String getmmscPortNumber() {
        return getPropertyAsString(mmscPortNumber);
    }

    public void setmmscPortNumber(String newmmscPortNumber) {
    	setProperty(mmscPortNumber, newmmscPortNumber);
    }
    
	public String getmmscUserName() {
        return getPropertyAsString(mmscUserName);
    }

    public void setmmscUserName(String newmmscUserName) {
    	setProperty(mmscUserName, newmmscUserName);
    }
    
	public String getmmscPwd() {
        return getPropertyAsString(mmscPwd);
    }

    public void setmmscPwd(String newmmscPwd) {
    	setProperty(mmscPwd, newmmscPwd);
    }
    
	public String getmmscConnType() {
        return getPropertyAsString(mmscConnType);
    }

    public void setmmscConnType(String newmmscConnType) {
    	setProperty(mmscConnType, newmmscConnType);
    }
    
	public String getmmSenderAddr() {
        return getPropertyAsString(mmSenderAddr);
    }

    public void setmmSenderAddr(String newmmSenderAddr) {
    	setProperty(mmSenderAddr, newmmSenderAddr);
    }
    
	public String getmmRecipientAddr() {
        return getPropertyAsString(mmRecipientAddr);
    }

    public void setmmRecipientAddr(String newmmRecipientAddr) {
    	setProperty(mmRecipientAddr, newmmRecipientAddr);
    }
    
	public String getserviceCode() {
        return getPropertyAsString(serviceCode);
    }

    public void setserviceCode(String newserviceCode) {
    	setProperty(serviceCode, newserviceCode);
    }
    
	public String getmsgClass() {
        return getPropertyAsString(msgClass);
    }

    public void setmsgClass(String newmsgClass) {
    	setProperty(msgClass, newmsgClass);
    }

    public String getdeliveryReport() {
        return getPropertyAsString(deliveryReport);
    }

    public void setdeliveryReport(String newdeliveryReport) {
    	setProperty(deliveryReport, newdeliveryReport);
    }


    public String getreadReplyReport() {
        return getPropertyAsString(readReplyReport);
    }

    public void setreadReplyReport(String newreadReplyReport) {
    	setProperty(readReplyReport, newreadReplyReport);
    }


    public String getcontentType() {
        return getPropertyAsString(contentType);
    }

    public void setcontentType(String newcontentType) {
    	setProperty(contentType, newcontentType);
    }

    public String getReplaceCancel() {
        return getPropertyAsString(replaceCancel);
    }

    public void setReplaceCancel(String newReplaceCancel) {
    	setProperty(replaceCancel, newReplaceCancel);
    }

    public String getTimerValue() {
        return getPropertyAsString(timerValue);
    }

    public void setTimerValue(String newtimerValue) {
    	setProperty(timerValue, newtimerValue);
    }

}
